package pikes.ecma;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class Expression extends PrintableExpression implements IExpression {

	private List<IAssignmentExpression> list = new LinkedList<IAssignmentExpression>();

	public Expression(final IAssignmentExpression assignmentExpression) {
		add(assignmentExpression);
	}

	public void add(final IAssignmentExpression assignmentExpression) {
		list.add(assignmentExpression);
	}

	public void visit(final SyntaxTreeVisitor syntaxTreeVisitor) throws EcmaSyntaxVisitingException {
		Iterator<IAssignmentExpression> iList = list.iterator();
		while (iList.hasNext()) {
			iList.next().visit(syntaxTreeVisitor);
			if (iList.hasNext()) {
				syntaxTreeVisitor.comma();
			}
		}
	}
}
